#![allow(dead_code)]

#[derive(Debug)]
struct Person {
    name: String,
    age: u8,
}


struct Point {
    x: f32,
    y: f32,
}

struct Rectangle {
    top_left: Point,
    bottom_right: Point,
}


struct Unit;
struct Pair(i32, f32);

pub fn main(){
    let name = String::from("Peter");
    let age = 27;
    let peter = Person{ name, age};

    println!("{:?}", peter);


    let point: Point = Point {x: 10.3, y : 0.4};
    println!("point coordinates: ({}, {})", point.x, point.y);

    let bottom_right = Point {x: 5.2, ..point};
    println!("second point: ({}, {})", bottom_right.x, bottom_right.y);

    //### destructure struct => pointusing a 'let'  binding !!!!
    let Point {x: left_edge, y: top_edge } = point;
    
    //use it 
    let _rectange = Rectangle {
        top_left: Point {x: left_edge, y: top_edge },
        bottom_right: bottom_right,
    };


    let _unit = Unit;
    let pair = Pair (1, 0.1);

    println!("pair contains {:?} and {:?}", pair.0, pair.1);

    //##### destructure a tuple struct
    let Pair(integer, decimal) = pair;

    println!("pair contains {:?} nad {:?}", integer, decimal);
}
